package fr.emse.tatiana.commands;


import org.eclipse.jface.action.Action;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;


import fr.emse.tatiana.CorpusNavigationView;
import fr.emse.tatiana.importexport.ExportCorpusWizard;

/**
 * Not yet properly implemented
 * 
 * @author dyke
 *
 */
public class ExportAction extends Action {
	protected final IWorkbenchWindow window;
	private final String navigationId;

	private static ExportAction instance;

	public static ExportAction getInstance() {
		return instance;
	}

	public ExportAction(IWorkbenchWindow window, String label, String navigationId) {
		this.window = window;
		this.navigationId = navigationId;
		setText(label);
		// The id is used to refer to the action in a menu or toolbar
		setId(ICommandIds.CMD_EXPORT);
		// Associate the action with a pre-defined command, to allow key bindings.
		//setActionDefinitionId(ICommandIds.CMD_FILTER);
		setImageDescriptor(fr.emse.tatiana.Activator.getImageDescriptor("/icons/export_wiz.gif"));
		this.setEnabled(false);
		instance = this;
	}


	@Override
	public void run() {
		if(window != null) {
			ExportCorpusWizard wizard = new ExportCorpusWizard();
			wizard.init(window.getWorkbench(),((CorpusNavigationView) window.getActivePage().findView(this.navigationId)).getSelectedProject());
			WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
			dialog.create();
			dialog.open();
		}
	}
}
